home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-06-23 | 2.5 KB | 92 lines |
- /*
- * QuickTime for Java SDK Sample Code
-
- Usage subject to restrictions in SDK License Agreement
- * Copyright: © 1996-1999 Apple Computer, Inc.
-
- */
- import java.awt.*;
- import java.awt.event.*;
- import java.util.*;
- import javax.swing.*;
-
- import quicktime.*;
- import quicktime.app.QTFactory;
- import quicktime.app.players.*;
- import quicktime.app.display.*;
- import quicktime.app.audio.*;
- import quicktime.io.*;
- import quicktime.std.*;
- import quicktime.std.movies.*;
- import quicktime.std.movies.media.*;
-
- import mixer.*;
- import mixer.display.*;
- import mixer.mc.*;
-
- /** This is the main class in our Mixer. It will display a window with the movie
- * and create a mixer to control the movie from.
- */
- public final class MusicMixer extends JFrame {
- private QTCanvas myCanvas;
- private QTPlayer myPlayer;
- private MixerDialog myMixer;
-
- public static void main (String args[]) {
- try {
- QTSession.open();
-
- Frame f = new MusicMixer("Movie");
- f.setVisible(true);
- f.toFront();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /** The constructor opens a movie, creates a window to display it in, and then
- * creates the mixer with the movie.
- * @param name the name of the window with the movie in it
- */
- public MusicMixer(String name) throws Exception {
- super(name);
-
- Container cp = getContentPane();
- cp.setLayout(null);
-
- QTFile movieFile = new QTFile (QTFactory.findAbsolutePath ("AudioMIDI.mov"));
- OpenMovieFile infile = OpenMovieFile.asRead(movieFile);
- Movie myMovie = Movie.fromFile(infile);
- infile.close();
-
- // prepare to show movie
- myCanvas = new QTCanvas();
- cp.add(myCanvas);
- addNotify();
- MovieController mc = new MovieController(myMovie);
- Insets insets = getInsets();
- setBounds(0, 0, (insets.left + insets.right + mc.getBounds().getWidth()),
- (insets.top + insets.bottom + mc.getBounds().getHeight()));
- myPlayer = new QTPlayer(mc);
- myCanvas.setClient(myPlayer, true);
-
- // build up the mixer control panel
- MixerDialog.parentFrame = this;
- MixerDialog.defaultName = "Mix:" + movieFile.getName();
- myMixer = new MixerDialog (new MasterDisplay (new MixerMovie (myPlayer)));
-
- // add the window listener to the main window
- addWindowListener(new WindowAdapter() {
- public void windowClosing (WindowEvent e) {
- myCanvas.removeClient();
- QTSession.close();
- dispose();
- }
-
- public void windowClosed (WindowEvent e) {
- System.exit(0);
- }
- });
- }
- }